Configuring FreePBX 15 for inbound calls
We have talked in the previous tutorial about installing FreePBX. Now let's talk about creating a trunk for inbound calls.
What you will need:
- a functional FreePBX
- a single SIP account (or multiple ones, for redundancy)
- one or more DIDs
- a configured FreePBX
A functional FreePBX:
Please refer to this tutorial about installing FreePBX: https://multitel.net/docs/view/671/tutorials/installing-freepbx
A single SIP account (or multiple ones, for redundancy)
You can start by creating a SIP account here: https://multitel.net/trunks/accounts
Click on the "Create New" button. A new window will show up. Copy the SIP Username and SIP password and save them in your notes. You will need them later.
Click on the Submit button once done.
In our example, we have created the following SIP account:
SIP Username: 1433369182
SIP Password: AjYaPthnvqFU182E
(These will be a different SIP Username/Password in your case. Use your own SIP username and SIP password. These ones above have been deleted after this tutorial was written)
Now for the SIP proxy to use, you can choose one of the following (listed alphabetically):
Continent | Country | SIP Proxy |
Africa | South Africa | sbc-za.multitel.net |
Asia | Singapore | sbc-sg.multitel.net |
Australia and Oceania | Australia | sbc-au.multitel.net |
Europe | Netherlands | sbc-nl.multitel.net |
Europe | Germany | sbc-de.multitel.net |
Europe | United Kingdom | sbc-uk.multitel.net |
North America | Canada | sbc-ca.multitel.net |
North America | United States of America | sbc-us.multitel.net |
South America | Brazil | sbc-br.multitel.net |
So, if you are located in Europe, you would choose one of the European based SIP proxies. You can ping each one of them and determine which one is closer to your location:
In my own testing, sbc-ca.multitel.net was the closest one, with around 20-21ms round trip times.
So, my credentials for this tutorial will now be:
SIP Username: 1433369182
SIP Password: AjYaPthnvqFU182E
SIP Proxy: sbc-ca.multitel.net
One or more DIDs:
You can buy a DID number here: https://multitel.net/numbers/rent
OR
You can use one of your existing numbers: https://multitel.net/numbers/inventory
OR
You can Bring Your Own Carrier: https://multitel.net/numbers/byoc
Whatever you do, you will end up here:
https://multitel.net/numbers/inventory
You will need to make sure that your DIDs are sending you calls from the same SIP Proxy that you are using for SIP registration. Here's how to do that:
Edit the number:
First go here: https://multitel.net/numbers/inventory
Search for the number, and click on the Edit Number button:
Find the "Origination trunk" setting and set it to "sbc-ca.multitel.net" -- or whatever is the closest SIP server to your location.
Next, make sure that the DID is sending the calls to your SIP account.
Set the "Call Action" menu to "SIP Account" , and make sure that the "SIP Account" menu is set to the SIP account that you are going to use.
Now everything that you needed to do on MultiTEL's portal is done. Let's go to the next step:
A configured FreePBX:
Open up your FreePBX server in a web browser:
Click on "FreePBX Administration" . You will be asked for your username and password. Remember that you set these in our previous tutorial, titled "Installing FreePBX"
You can probably skip the activation. Up to you.
You might get some new windows with commercials. Up to you if you want to click or skip them. For the sake of keeping this tutorial short, I will skip them.
I had to select the locales:
There might be some other commercials showing up , I advise you skip them, or click on "Abort" if no "Skip" button is available.
I will go directly to "Connectivity" and choose "Trunks":
Click on the "Add Trunk" button, and choose "Add SIP (chan_pjsip) Trunk":
Here's what to set in the new window:
Trunk Name: You can safely set it to MultiTEL
Maximum Channels: whatever you feel is safe. It depends on your call volumes, and it also depends on how much you are willing to pay (or not pay) for concurrent calls. Most of the numbers we sell come with 2 dedicated channels , which allows you to receive 2 simultaneous calls free of charge. All additional calls will be charged . If you do not wish to get charged for additional simultaneous calls, set this field to "2"
Asterisk Trunk Dial Options: I always like to generate ring tone, so I will click on the "Override" button and set the options to "Ttr" ("Tt" - allow calling/called party to transfer the call, "r" - generate ring)
Next, move to the "pjsip Settings" tab.
Fill in with the SIP credentials we got on the "A single SIP account" step.
SIP Username: 1433369182
SIP Password: AjYaPthnvqFU182E
SIP Proxy: sbc-ca.multitel.net
As a reminder, use your own SIP credentials. These credentials above DO NOT exist anymore and were only used for the purpose of writing this tutorial. Attempting to use these non-existing test credentials will get your IP address banned.
At a minimum, these are the settings I will configure:
Note that I have changed the context to "from-multitel" (this was initially set as "from-pstn"). This change is important, as it allows us to further process calls from multiple inbound DIDs using a single SIP account (rather than one SIP account per each DID).
In the Codecs tab, I will only keep ulaw and alaw:
I will click on the Submit button:
And then ignore the pop-up menu that shows up (I like setting up the outbound CID on the extensions, rather than one outbound CID per trunk. This way I can have multiple callerids used on a single trunk, rather than having to define multiple trunks, one for each callerid I need my callers to use)
So go ahead and click "OK"
The page will refresh and you will now see your new SIP trunk. Click on the "Apply Config" red button on upper right hand side of the screen:
Once the screen refreshes and the red Apply Config button is gone, you might want to check in asterisk CLI to see if your SIP account has registered successfully.
Login with SSH to your FreePBX server and do:
asterisk -rx 'pjsip show registrations' | grep multitel
You should see an output similar to the one below:
Now that the SIP registration is working, let's create an inbound route for our DID(s).
Go to "Connectivity" and choose "Inbound Routes":
Click on the "Add Inbound Route" button.
For the purposes of this test, I will just make inbound calls go to the Echo test:
After saving, we will get redirected to the main Inbound routes screen:
We are almost done now. For the time being, click on the red "Apply Config" button on the top right hand side of the screen.
Remember that when we were setting up the SIP trunk we changed the context to "from-multitel" ? The last step is to add that context.
We will have to do that from the server's console:
nano /etc/asterisk/extensions_custom.conf
Add the following lines:
[from-multitel]
; exten => s,1,Set(DID=${SIP_HEADER(X-DID)}) ; set this if using chan_sip
exten => s,1,Set(DID=${PJSIP_HEADER(read,X-DID)}) ; set this if using chan_pjsip
exten => s,2,Goto(from-pstn,${DID},1)
Save (CTRL+O , Enter , CTRL+X ) , and then reload the asterisk dialplan:
asterisk -rx 'dialplan reload'
You are all done now, your inbound calls should now go through with no issues. You can now have multiple DIDs, all using the same SIP account.
PS: how does this work? We set the SIP account to use a custom context , "from-multitel". Then, in the "from-multitel" context, we process a SIP variable called "X-DID" , and set the called number to that. Then, the call is sent back to the "from-pstn" context.
Similar Articles
Creating a trunk for inbound calls in FreePBX
READ MOREProvisioning and deploying E911
READ MOREUsing Multitel as your outbound call provider with plain Asterisk
READ MORESetting up your SIP Account on iPhone using App Store
READ MORESetting up your SIP account on Android using Google Play
READ MORE